package com.marlowe.asyouknow.controller;

import com.marlowe.asyouknow.service.ParseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;


/**
 * @program: as-you-know
 * @description: 爬虫controller
 * @author: Marlowe
 * @create: 2020-12-21 11:24
 **/
@Api(tags = "爬虫控制类")
@RestController
public class ParseController {
    @Autowired
    private ParseService parseService;

    @ApiOperation(value = "爬取京东")
    @GetMapping("/parseJd/{keyword}")
    public Boolean parseJd(@PathVariable("keyword") String keyword) throws IOException {
        return parseService.parseJD(keyword);
    }

    @ApiOperation(value = "爬取南方周末")
    @GetMapping("/parseNews")
    public Boolean parseNews() throws Exception {
        return parseService.parseNews();
    }

    @ApiOperation(value = "爬取百度图库")
    @GetMapping("/parsePictures")
    public Boolean parsePictures() throws Exception {
        return parseService.parsePictures();
    }
}
